<?php
/**
 * User: hjd-yao
 * Date: 2019/5/9
 * Time: 12:54
 */

namespace App\Http\Controllers\User;


use App\Helpers\Search;
use App\Helpers\SelfResponse;
use App\Http\Controllers\BackendController;
use App\Models\Store\ShopStoreModel;
use App\Models\Store\ShopStoreWdModel;
use App\Models\User\AccountFlowModel;
use App\Models\User\TfRecordModel;
use Carbon\Carbon;
use DC\UserCenter\Models\UserBaseModel;
use DC\UserCenter\Models\UserWalletModel;
use Illuminate\Http\Request;


class TfController extends BackendController
{

    /**
     * @title 转账记录
     * @param Request $request
     * @return View
     */
    public function tfRecord(Request $request)
    {
        $search = Search::make($request)->bindModel(TfRecordModel::with('user','to_users')->has('user'))
            ->input('user','编号/姓名/手机号','',['field'=>'out_uid'])
            ->time('created_at','申请时间')
            ->bindSearchData()->relationModel(['user'=>function($value){
                return UserBaseModel::where('user_number',$value)
                    ->orWhere('real_name',$value)->orWhere('user_phone',$value)->pluck('member_id')->toArray();
            }]);
        $list = $search->where()->whereIn('status',[-1,1])->orderBy('created_at','desc')
            ->paginate($this->getPerPageNum());

        return view('backend::account.tf_record',[
            'page_title'=>'转账记录',
            'list'=>$list,
            'search'=>$search
        ]);
    }

}